Conversation
This reverts commit b28db62
| import java.util.TreeMap; | ||
|
|
||
| @Data | ||
| public class SeaBattle { |
There was a problem hiding this comment.
I couldn't play the game... it just takes so long to start, to place ships manually for 2 players, especially because I need to input all the cells of a ship... Please refactor, I'll check then
| @@ -0,0 +1,7 @@ | |||
| package homework_2.random_chars_table; | |||
|
|
|||
| public class Main { | |||
There was a problem hiding this comment.
Good HW_2, with enums and inner classes!
| @CustomAnnotation(v = 1.2f) | ||
| public class Main { | ||
| public static void main(String[] args) { | ||
| new Main().run(); |
| import java.nio.channels.FileChannel; | ||
| import java.nio.charset.StandardCharsets; | ||
|
|
||
| public class CustomFileReader { |
There was a problem hiding this comment.
Opt: unnessessary method boxing and inner try-catches... seems not needed
There was a problem hiding this comment.
Looks like the code is hard to read without a reason
There was a problem hiding this comment.
Why all methods are public?
There was a problem hiding this comment.
Tests ((... How can I test them then?
There was a problem hiding this comment.
You shouldn't test all methods. If your app is well-incapsulated, it has a few public methods (aka API of your class) and many private methods
| System.out.println(singleGameHero2.hashCode() + ", age: " + singleGameHero2.getAge() + ", name: " + singleGameHero2.getName()); | ||
| } | ||
|
|
||
| private Singleton() {} |
| } | ||
|
|
||
| @Override | ||
| public boolean equals(Object obj) { |
There was a problem hiding this comment.
I'm really confused why all your methods in most of HW are public. By this you break one of the OOP principles - incapsulation
There was a problem hiding this comment.
Oh ((. It's because of the tests. I need to learn to test private methods (or to build the architecture correctly).
There was a problem hiding this comment.
You shouldn't test private methods
There was a problem hiding this comment.
A-a-ah... I didn't know, I wrote all methods as private, but with the writing tests to them I needed to change them to public.
| Random random = new Random(); | ||
| return random.nextInt(); |
There was a problem hiding this comment.
We looked at this problem on the lecture, right?
There was a problem hiding this comment.
Fixed (object's hashcode tied to the field's hashcode (date of birth)).
| KittenToCatFunction<Kitten, Cat> function = k -> new Cat(k.getName(), k.getSex(), k.getAgeInMonths() / 12, k.getColour()); | ||
| Cat[] cats = kittens.stream().map(k -> function.grow(k)).toArray(Cat[]::new); | ||
| Arrays.stream(cats).forEach(System.out::println); |
NikolaevArtem
left a comment
There was a problem hiding this comment.
Pretty good! You show good knowledge of Java Core and Java libraries, in HW you experimented with its features, and it looks in place. There are some minor issues to fix, and most important is - please fix Cource Project and ping me as soon as done
| @@ -27,7 +27,8 @@ private enum Section { | |||
| private final Calendar yearOfPublishing; | |||
| private final int numberOfPages; | |||
There was a problem hiding this comment.
Your class is 100% mutable
There was a problem hiding this comment.
Ah, yearOfPublishing is a reference object (Calendar), that's why I have to return not current instance but also it's copy as Author?
There was a problem hiding this comment.
We care about reference type, mutable fields (you have 2 - Author and Calendar)
There was a problem hiding this comment.
Still not correct) Repeat the topic when you have time
There was a problem hiding this comment.
I'll look at smarter students, I think, there is something I don't understand but I want very much.
There was a problem hiding this comment.
Ok, I understood, we needn't setters at all and we have to override some getters for reference fields.
| import java.util.*; | ||
|
|
||
| @Data | ||
| public class Field { |
There was a problem hiding this comment.
Good! The game is nice to play, the interface is good, playing is easy. Approved!
There was a problem hiding this comment.
Thanks for the science and advices!
No description provided.